import socket
import threading

cli = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
r = []
w = []

cli.connect(('127.0.0.1',6666))

def send():
    while 1:
        n = input('请输入：')
        cli.send(n.encode('utf8'))
        if n =='NO':
            break
def accept():
    while 1:
        m = cli.recv(1024).decode('utf8')
        if m == 'NO':
            cli.close()
            break
        else:
            print(m)

t1 = threading.Thread(target=send)
t2 = threading.Thread(target=accept)

t1.start()
t2.start()

t2.join()
t1.join()


